//
//  ERMethod.h
//  metadata
//
//  Created by easy on 11-5-30.
//  Copyright 2011 zeasy@qq.com. All rights reserved.
// 

#import "ERuntime.h"
//ERContext 环境下的 方法
@interface ERMethod : NSObject {
	Method source;
	ERMethodEntity *entity;
}
#pragma mark property
@property (nonatomic, readonly) Method source;
@property (nonatomic, readonly) NSString *name;
@property (nonatomic, readonly) NSUInteger numberOfArgument;
@property (nonatomic, readonly) ERClassType *returnType;
@property (nonatomic, readonly) NSArray /*ERClassType*/*argumentTypes;
@property (nonatomic, readwrite) IMP implementations;	//函数指针指向
@property (nonatomic, readonly) NSUInteger numberOfArgumentWithObject;
@property (nonatomic, readonly) NSArray /*ERClassType*/*argumentTypesWithObject;
#pragma mark init
-(id) initWithMethod:(Method) method;

//更改函数指针的指向
-(void) exchangeImplementations:(ERMethod *) method;
//索引出的参数类型
-(ERClassType *) argumentTypeAtIndex:(NSUInteger) index;
//根据对象的Method的参数类型，在对象方法中前两位类型分别标识对象本身，所以需要偏移2位
-(ERClassType *) argumentTypeWithObjectAtIndex:(NSUInteger) index;
//相对对象的参数个数，等于numberOfArgument - 2
//-(int) numberOfArgumentWithObject;
//相对对象的参数集，会去掉前两个<object,cmd>类型
//-(NSArray *) argumentTypesWithObject;

//invoke
@end


@interface ERMethodEntity : NSObject{
	NSMutableArray /*EClassType*/ *argumentTypes; 
	ERClassType *returnType;
	NSString *name;
}
-(id) initWithName:(NSString *) aName argumentTypes:(NSArray *) argTypes returnType:(ERClassType *) rtnType;
+(id) entityWithMethod:(Method) method;
#pragma mark property
@property (nonatomic, retain) NSMutableArray *argumentTypes;
@property (nonatomic, readonly) NSUInteger numberOfArgument;
@property (nonatomic, retain) ERClassType *returnType;
@property (nonatomic, retain) NSString *name;
@end
